package com.serviceprovider.business.module.order.services.impl;

//~--- non-JDK imports --------------------------------------------------------

import com.serviceprovider.business.module.common.Page;
import com.serviceprovider.business.module.order.model.Order;
import com.serviceprovider.business.module.order.model.OrderSearchCriteria;
import com.serviceprovider.business.module.order.services.dao.interfaces.IOrderDao;
import com.serviceprovider.business.module.order.services.interfaces.IOrderService;
import com.serviceprovider.business.module.order.valueobjects.OrderFilterConditionVO;
import com.serviceprovider.business.module.user.model.impl.User;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

//~--- JDK imports ------------------------------------------------------------

import java.util.List;

/**
 * DAO class which is used to work with Order
 *
 * @author mrduongnv@gmail.com
 */
@Service("orderServiceImpl")
public class OrderServiceImpl implements IOrderService {
    @Autowired
    IOrderDao orderDetailDao;

    @Override
    public Order findOrderById(int id) {
        return orderDetailDao.findOrderById(id);
    }

    @Override
    public List<Order> findOrderByUserId(int userId) {
        return orderDetailDao.findOrderByUserId(userId);
    }

    @Override
    public Order findOrderByBatch(int bacthId) {
        return orderDetailDao.findOrderByBatch(bacthId);
    }

    @Override
    public Order findOrderByTransactionId(int transactionId) {
        return orderDetailDao.findOrderByTransactionId(transactionId);
    }

    @Override
    public List<Order> findOrderByshippingMode(String shippingMode) {
        return orderDetailDao.findOrderByshippingMode(shippingMode);
    }

    @Override
    public List<Order> findOrderByOrderStatus(String orderStatusName) {
        return orderDetailDao.findOrderByOrderStatus(orderStatusName);
    }

    @Override
    public List<Order> findOrderByDateRange(String startDate, String endDate) {
        return orderDetailDao.findOrderByDateRange(startDate, endDate);
    }

    @Override
    public List<Order> findOrderBySearchCriteria(OrderSearchCriteria criteria) {
        return orderDetailDao.findOrderBySearchCriteria(criteria);
    }

    public Page<Order> findOrderBySearchCriteria(OrderSearchCriteria criteria, int pageNo, int recordSize,
            String sortColumn, String sortOrder) {
        return orderDetailDao.findOrderBySearchCriteria(criteria, pageNo, recordSize, sortColumn, sortOrder);
    }

    @Override
    public Page<Order> findAll(int pageNumber, int pageSize, String sortColumn, String sortOrder) {
        return orderDetailDao.findAll(pageNumber, pageSize, sortColumn, sortOrder);
    }

    @Override
    public Page<Order> findOrderByUserId(int userId, int pageNumber, int pageSize, String sortColumn,
            String sortOrder) {
        return orderDetailDao.findOrderByUserId(userId, pageNumber, pageSize, sortColumn, sortOrder);
    }

    @Override
    public Order insertOrder(Order order) {
        return orderDetailDao.insertOrder(order);
    }

    @Override
    public void updateOrder(Order order) {
        orderDetailDao.updateOrder(order);
    }

    @Override
    public void updateStatus(int orderid, int statusid) {
        orderDetailDao.updateStatus(orderid, statusid);
    }

    @Override
    public void updateAssignedUserIds(Integer orderId, Integer assignedUserId) {
        orderDetailDao.updateAssignedUserIds(orderId, assignedUserId);
    }

    @Override
    public void deleteOrder(int orderId) {
        orderDetailDao.deleteOrder(orderId);
    }

    @Override
    public void saveOrderComments(String comment, int orderID) {
        orderDetailDao.saveOrderComments(comment, orderID);
    }

    @Override
    public void updateComment(int commentId, String newComment) {
        orderDetailDao.updateComment(commentId, newComment);
    }

    @Override
    public void deleteComment(int commentId) {
        orderDetailDao.deleteComment(commentId);
    }

    @Override
    public List<String> findComments(int orderId) {
        return orderDetailDao.findComments(orderId);
    }

    @Override
    public List<User> findAllProviders() {
        return orderDetailDao.findAllProviders();
    }

    @Override
    public void deleteByBatchId(Integer batchId) {
        orderDetailDao.deleteByBatchId(batchId);
    }

    @Override
    public List<Order> getAllUsingFilter(List<OrderFilterConditionVO> list) {
        return orderDetailDao.getAllUsingFilter(list);
    }

    public Page<Order> getAllUsingFilter(List<OrderFilterConditionVO> list, int pageNo, int recordSize,
            String sortColumn, String sortOrder) {
        return orderDetailDao.getAllUsingFilter(list, pageNo, recordSize, sortColumn, sortOrder);
    }
}



